/*
 *  Copyright (C) 2010 Martin Haulrich <mwh.isv@cbs.dk>
 *
 *  This file is part of the MatrixParser package.
 *
 *  The MatrixParser program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.osdtsystem.matrixparser.data;

import java.util.List;

/**
 *
 * @author Martin Haulrich
 */
public class CONLLSentence {

    public static final String NEWLINE = System.getProperty("line.separator");
    public List<CONLLToken> words;
    
    public CONLLSentence(List<CONLLToken> words) {
        this.words = words;
    }

    public int size() {
        return words.size();
    }

    public CONLLToken get(int i) {
        return words.get(i);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CONLLSentence other = (CONLLSentence) obj;
        if (this.words != other.words && (this.words == null || !this.words.equals(other.words))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + (this.words != null ? this.words.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (CONLLToken w : words) {
            sb.append(w.toString());
            sb.append(NEWLINE);
        }
        return sb.toString();
    }

    public String toTokenString() {
        StringBuilder sb = new StringBuilder();
        for (CONLLToken w : words) {
            sb.append(w.get(CONLLToken.FORM));
            sb.append(" ");
        }
        return sb.toString();
    }
}
